import { defineConfig } from "eslint/config";
import typeScriptParser from "@typescript-eslint/parser";
import typeScriptPlugin from "@typescript-eslint/eslint-plugin";

export default defineConfig([
	{
		files: ["**/src/**/*.{ts,tsx}"],
		ignores: ["./editor/src/ui/shadcn/**/*.{ts,tsx}", "./templates/**/src/scripts.ts", "./website/src/scripts.ts"],
		languageOptions: {
			ecmaVersion: "latest",
			parser: typeScriptParser,
		},
		plugins: {
			"@typescript-eslint": typeScriptPlugin,
		},
		rules: {
			// Recommended
			"eol-last": ["error", "always"],
			"no-useless-constructor": "error",
			"no-debugger": "error",
			eqeqeq: ["error", "always"],
			curly: ["error", "all"],
			"no-constant-binary-expression": "warn",
			"max-params": ["warn", 6],
			"no-sparse-arrays": "error",
			"array-callback-return": "error",
			"constructor-super": "error",
			"getter-return": "error",
			"no-class-assign": "error",
			"no-compare-neg-zero": "error",
			"no-cond-assign": "error",
			"no-constant-binary-expression": "error",
			"no-constant-condition": "error",
			"no-constructor-return": "error",
			"no-control-regex": "error",
			"no-dupe-args": "error",
			"no-dupe-class-members": "error",
			"no-dupe-else-if": "error",
			"no-dupe-keys": "error",
			"no-duplicate-case": "error",
			"no-duplicate-imports": "error",
			"no-empty-character-class": "error",
			"no-empty-pattern": "error",
			"no-func-assign": "error",
			"no-import-assign": "error",
			"no-inner-declarations": "error",
			"no-invalid-regexp": "error",
			"no-irregular-whitespace": "error",
			"no-loss-of-precision": "error",
			"no-misleading-character-class": "error",
			"no-new-native-nonconstructor": "error",
			"no-obj-calls": "error",
			"no-self-compare": "error",
			"no-setter-return": "error",
			"no-template-curly-in-string": "error",
			"no-this-before-super": "error",
			"no-unassigned-vars": "error",
			"no-unexpected-multiline": "error",
			"no-unmodified-loop-condition": "error",
			"no-unreachable": "error",
			"no-unreachable-loop": "error",
			"no-unsafe-finally": "error",
			"no-unsafe-negation": "error",
			"no-unsafe-optional-chaining": "error",
			"no-unused-private-class-members": "error",
			"no-use-before-define": [
				"error",
				{
					functions: false,
					classes: false,
					variables: true,
					allowNamedExports: false,
				},
			],
			"no-useless-backreference": "error",
			"use-isnan": "error",
			"valid-typeof": "error",

			"@typescript-eslint/naming-convention": [
				"error",
				{
					selector: "enumMember",
					format: ["PascalCase"],
				},
				{
					selector: "function",
					format: ["camelCase", "PascalCase"],
					leadingUnderscore: "allow",
				},
				{
					selector: "interface",
					format: ["PascalCase"],
					prefix: ["I"],
					leadingUnderscore: "allow",
				},
				{
					selector: "memberLike",
					modifiers: ["private"],
					format: ["camelCase"],
					leadingUnderscore: "require",
				},
			],

			// Suggestions
			"block-scoped-var": "error",
			"func-names": ["error", "never"],
			"guard-for-in": "error",
			"logical-assignment-operators": ["error", "always"],
			"no-alert": "error",
			"no-delete-var": "error",
			"no-else-return": "error",
			"no-eval": "error",
			"no-extra-label": "error",
			"no-global-assign": "error",
			"no-implied-eval": "error",
			"no-invalid-this": "error",
			"no-lonely-if": "error",
			"no-new-func": "error",
			"no-new-wrappers": "error",
			"no-nonoctal-decimal-escape": "error",
			"no-object-constructor": "error",
			"no-octal": "error",
			"no-octal-escape": "error",
			"no-proto": "error",
			"no-script-url": "error",
			"no-sequences": "error",
			"no-useless-escape": "error",
			"no-useless-rename": "error",
			"no-var": "error",
			"no-useless-return": "error",
			yoda: ["error", "never"],
		},
	},
]);
